﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using ExaminationSys.DataAccess;
using ExaminationSys.DataAccess.Repository;
using Ext.Net;
using ExaminationSys.DataAccess.Entity;

namespace ExaminationSys.View.SystemManage
{
    public partial class SysUserEdit : System.Web.UI.UserControl
    {
        private static readonly Sys_UserService Proxy = ObjectFactory<Sys_UserService>.Create();

        protected void Page_Load(object sender, EventArgs e)
        {

        }


        public Store GridStore { get; set; }
        public string ID { get; set; }


        public void SetData(Sys_UserEntity sysUserEntity)
        {

            if (sysUserEntity != null)
            {
                this.UserType.Value = sysUserEntity.UserType;
                this.UserNo.Value = sysUserEntity.UserNo;
                this.UserName.Value = sysUserEntity.UserName;
                this.LoginName.Value = sysUserEntity.LoginName;
                this.Diminutive.Value = sysUserEntity.Diminutive;
                this.Password.Value = sysUserEntity.Password;
                this.Sex.Value = sysUserEntity.Sex;
                this.Birthday.Value = sysUserEntity.Birthday;
                this.CollegeName.Value = sysUserEntity.CollegeName;
                this.MajorName.Value = sysUserEntity.MajorName;
                this.ClassName.Value = sysUserEntity.ClassName;
                this.Title.Value = sysUserEntity.Title;
                this.Rights.Value = sysUserEntity.Rights;
                this.Mobile.Value = sysUserEntity.Mobile;
                this.Telphone.Value = sysUserEntity.Telphone;
                this.Email.Value = sysUserEntity.Email;
                this.UserAddress.Value = sysUserEntity.UserAddress;
                this.SecurityQuestion.Value = sysUserEntity.SecurityQuestion;
                this.SecurityAnswer.Value = sysUserEntity.SecurityAnswer;
                this.IsCenttypeNOValid.Value = sysUserEntity.IsCenttypeNOValid;
                this.IsFreeze.Value = sysUserEntity.IsFreeze;
                this.UserImage.Value = sysUserEntity.UserImage;
                this.WorkAddress.Value = sysUserEntity.WorkAddress;
                this.SelfIntroduction.Value = sysUserEntity.SelfIntroduction;
                this.Url.Value = sysUserEntity.Url;
                this.EmailActivationAddress.Value = sysUserEntity.EmailActivationAddress;
                this.EmailActivationTime.Value = sysUserEntity.EmailActivationTime;
                this.Remark1.Value = sysUserEntity.Remark1;
                this.Remark2.Value = sysUserEntity.Remark2;
                this.Remark3.Value = sysUserEntity.Remark3;
                this.LockKey.Value = sysUserEntity.LockKey;
                this.DeleteKey.Value = sysUserEntity.DeleteKey;


                ID = sysUserEntity.UserID.ToString();
                X.Js.Call("setID", ID);

            }

            //set tips for htmleditor
            //var tips=new HtmlEditorButtonTips();
            //tips.Bold.Title = "粗体 (Ctrl+B)";
            //tips.Bold.Text = "设置字体样式为粗体";

            //tips.Italic.Title = "斜体 (Ctrl+I)";
            //tips.Italic.Text = "设置字体样式为斜体";

        }

        public void Show()
        {
            this.EditWindow.Show();
        }

        protected void SaveEntity(object sender, DirectEventArgs e)
        {
            Sys_UserEntity sysUserEntity = new Sys_UserEntity();
            sysUserEntity.UserType = this.UserType.Value.ToString();
            sysUserEntity.UserNo = this.UserNo.Value.ToString();
            sysUserEntity.UserName = this.UserName.Value.ToString();
            sysUserEntity.LoginName = this.LoginName.Value.ToString();
            sysUserEntity.Diminutive = this.Diminutive.Value.ToString();
            sysUserEntity.Password = this.Password.Value.ToString();
            sysUserEntity.Sex = this.Sex.Value.ToString();
            sysUserEntity.Birthday = this.Birthday.Value.ToString();
            sysUserEntity.CollegeName = this.CollegeName.Value.ToString();
            sysUserEntity.MajorName = this.MajorName.Value.ToString();
            sysUserEntity.ClassName = this.ClassName.Value.ToString();
            sysUserEntity.Title = this.Title.Value.ToString();
            sysUserEntity.Rights = this.Rights.Value.ToString();
            sysUserEntity.Mobile = this.Mobile.Value.ToString();
            sysUserEntity.Telphone = this.Telphone.Value.ToString();
            sysUserEntity.Email = this.Email.Value.ToString();
            sysUserEntity.UserAddress = this.UserAddress.Value.ToString();
            sysUserEntity.SecurityQuestion = this.SecurityQuestion.Value.ToString();
            sysUserEntity.SecurityAnswer = this.SecurityAnswer.Value.ToString();
            sysUserEntity.IsCenttypeNOValid = this.IsCenttypeNOValid.Value.ToString();
            sysUserEntity.IsFreeze = this.IsFreeze.Value.ToString();
            sysUserEntity.UserImage = this.UserImage.Value.ToString();
            sysUserEntity.WorkAddress = this.WorkAddress.Value.ToString();
            sysUserEntity.SelfIntroduction = this.SelfIntroduction.Value.ToString();
            sysUserEntity.Url = this.Url.Value.ToString();
            sysUserEntity.EmailActivationAddress = this.EmailActivationAddress.Value.ToString();
            sysUserEntity.EmailActivationTime = this.EmailActivationTime.Value.ToString();
            sysUserEntity.Remark1 = this.Remark1.Value.ToString();
            sysUserEntity.Remark2 = this.Remark2.Value.ToString();
            sysUserEntity.Remark3 = this.Remark3.Value.ToString();
            sysUserEntity.LockKey = Convert.ToInt32(this.LockKey.Value);
            sysUserEntity.DeleteKey = 0;

        }
    }
}